<%@ page import="java.sql.Statement" import="java.sql.ResultSet" import="java.sql.Connection" import="java.sql.DriverManager"%>
<%@page import="connection.DBConnection"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Receipts Periodic Report</title>
</head>
<body>
<h2 align="center"> Receipts Periodic Report</h2>
<form name="fr14" method="post">

  <%
        String exportToExcel = request.getParameter("exportToExcel");
        if (exportToExcel != null && exportToExcel.toString().equalsIgnoreCase("YES")) 
        {
            response.setContentType("application/vnd.ms-excel");
            response.setHeader("Content-Disposition", "inline; filename=" + "ReceiptsPeriodicReport.xls");
 
        }
    %>

<table border=1 align="center"> 

<tr>
		<th> Bank Name </th>
		<th> Receipts Entry number </th>
		<th> Date </th>
		<th> Cheque Number </th>
		<th> Account Name </th>
		<th> Amount </th>
		<th> Account Name</th>
		<th> Amount </th>
		<th> Narration </th>
</tr>

		<%
        String dte=(String) request.getAttribute("frmdte");
		 String dte1=(String) request.getAttribute("todte");
			
			double amount6=0.0,amount8=0.0;
			double rv6=0.0,rv8=0.0;
			
			try
			{
				String qry;
                Class.forName("com.mysql.jdbc.Driver");
                Connection con = DriverManager.getConnection("jdbc:mysql://localhost/boa","root","root");
                Statement s = con.createStatement();                
                qry=" Select * from receiptsvoucher where CAST(date as DATE) between '"+dte+"' and '"+dte1+"';";
                ResultSet rs=s.executeQuery(qry);
       		  while(rs.next()){ %>
<tr>
            		<td><%= rs.getString(1)%></td>
            		<td><%= rs.getString(2)%></td>
            		<td><%= rs.getString(3)%></td>
            		<td><%= rs.getString(4)%></td>
            		<td><%= rs.getString(5)%></td>
            		
            		<% rv6= rs.getDouble(6); %>
            		<td><%=rv6%></td>
            		<td><%= rs.getString(7)%></td>
            		
            		<% rv8= rs.getDouble(8); %>
            		<td><%=rv8%></td>
            		<td><%= rs.getString(9)%></td>
            		
</tr>
        		<% 	amount6=amount6+rv6;
        			amount8=amount8+rv8;
        			} %>
  
	 		<% }
			catch(Exception e){} %>
			
<tr>
	<td> <b> Total </b></td>
	<td> </td>
	<td> </td>
	<td> </td>
	<td> </td>
	<td> <%=amount6 %></td>
	<td> </td>
	<td> <%=amount8 %></td>
	<td> </td>
</tr>			
			
<%--<tr>
		<td> ${CMR.rbname} </td> 
		<td> ${CMR.renum} </td>
		<td> ${CMR.date} </td>
		<td> ${CMR.rcheque} </td>
		<td> ${CMR.raccname} </td>
		<td> ${CMR.ramount} </td>
		<td> ${CMR.raccname2} </td>
		<td> ${CMR.ramount2} </td>
		<td> ${CMR.rnar} </td>

</tr>
--%>
</table>
<br><br> 
	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

    <%
        if (exportToExcel == null) {
    %>
    <a href="ReceiptsPeriodicReport.jsp?exportToExcel=YES">Export to Excel</a>
    <%
        }
    %>
</form>

</body>
</html>